home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / windows / win31 / macsyma.arj / MACSDEMO.EXE / BISECT.OUT < prev    next >
Text File  |  1993-09-15  |  1KB  |  43 lines

  1.  
  2. (c1) if get('bisect,'version)=false then load("bisect")$
  3. C:\MACSD2B\share\bisect.fas being loaded.
  4.  
  5. (c2) /* For purposes of the demo, set convergence tolerances */
  6.  
  7. (bisect_dep_toler : 1.0e-7,
  8.  bisect_indep_toler : 1.0e-7) $
  9.  
  10. (c3) /* Finding the numerical root of an expression  */
  11.  
  12. exp: x^5 - 5 ;
  13. |$label(0,15,Times New Roman,$(d3$))$sup(x,5)$hinge()$in( - )5
  14.  
  15. (c4) root_by_bisection(eval(exp),x,1,2);
  16. |$label(0,15,Times New Roman,$(d4$))1.37973
  17.  
  18. (c5) root_by_bisection(x^5-5,x,1,2);
  19. |$label(0,15,Times New Roman,$(d5$))1.37973
  20.  
  21. (c6) %^5;
  22. |$label(0,15,Times New Roman,$(d6$))4.99999
  23.  
  24. (c7) /* Equations are handled */
  25.  
  26. eqn: cos(x) = x;
  27. |$label(0,15,Times New Roman,$(d7$))cos$paren(x)$hinge()$in( = )x
  28.  
  29. (c8) root_by_bisection(eval(eqn),x,0,1);
  30. |$label(0,15,Times New Roman,$(d8$))0.73908
  31.  
  32. (c9) cos(%);
  33. |$label(0,15,Times New Roman,$(d9$))0.73908
  34.  
  35. (c10) /* So are functions */
  36.  
  37. f(x) := sin(x)^2 - ''(sfloat(1/%pi));
  38. |$label(0,15,Times New Roman,$(d10$))f$paren(x)$hinge()$in( := )$sup(sin,2)$paren(x)$in( - )0.31831
  39.  
  40. (c11) root_by_bisection('f,0,1);
  41. |$label(0,15,Times New Roman,$(d11$))0.59945
  42.  
  43.